package com.matrix.java.chap_05.example;

import java.util.Scanner;
/*
    最大公约数
 */
public class Case5_09 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("数1: ");
        int num1 = input.nextInt();
        System.out.print("数2: ");
        int num2 = input.nextInt();
        int commonDivisor = 0;
        for (int i = 1; i <= Math.min(num1, num2); i++) {
            int remainder1 = num1 % i;
            int remainder2 = num2 % i;
            if (remainder1 == 0 && remainder2 == 0) {
                commonDivisor = i;
            }
        }
        System.out.println("公约数: "+commonDivisor);
        input.close();
    }
}
